package com.department.mydepartment.entities;

import org.json.JSONObject;

import javax.persistence.*;
import java.sql.Timestamp;

@Entity
public class Article {

    //文章表
    @Id
    @Column(unique = true,length = 36)
    private String articleId;
    @Column(nullable = false)
    private String articleTitle;
    @Column(nullable = false)
    private String articleTag;
    @Column(nullable = false)
    private String articleType;
    @Column(nullable = false)
    private String fileUrl;
    @Column
    private String imgUrl;
    @Column(nullable = false)
    private Timestamp createTime;
    @Column(nullable = false)
    private Timestamp updateTime;

    public Article() {
    }

    public Article(String articleId, String articleTitle, String articleTag, String articleType, String fileUrl, String imgUrl, Timestamp createTime, Timestamp updateTime) {
        this.articleId = articleId;
        this.articleTitle = articleTitle;
        this.articleTag = articleTag;
        this.articleType = articleType;
        this.fileUrl = fileUrl;
        this.imgUrl = imgUrl;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public Article(String articleId, String articleTitle, String articleTag, String articleType, String fileUrl, Timestamp createTime, Timestamp updateTime) {
        this.articleId = articleId;
        this.articleTitle = articleTitle;
        this.articleTag = articleTag;
        this.articleType = articleType;
        this.fileUrl = fileUrl;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("articleId",articleId);
        jsonObject.accumulate("articleTitle",articleTitle);
        jsonObject.accumulate("articleTag",articleTag);
        jsonObject.accumulate("articleType",articleType);
        jsonObject.accumulate("fileUrl",fileUrl);
        jsonObject.accumulate("imgUrl",imgUrl);
        jsonObject.accumulate("createTime",createTime);
        jsonObject.accumulate("updateTime",updateTime);
        return jsonObject.toString();
    }

    public String getArticleId() {
        return articleId;
    }

    public void setArticleId(String articleId) {
        this.articleId = articleId;
    }

    public String getArticleTitle() {
        return articleTitle;
    }

    public void setArticleTitle(String articleTitle) {
        this.articleTitle = articleTitle;
    }

    public String getArticleTag() {
        return articleTag;
    }

    public void setArticleTag(String articleTag) {
        this.articleTag = articleTag;
    }

    public String getArticleType() {
        return articleType;
    }

    public void setArticleType(String articleType) {
        this.articleType = articleType;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }
}
